﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;

namespace l1cs.server.serverpackets
{
    public class S_CommonNews : ServerBasePacket
    {
        public S_CommonNews()
        {
            List<String> _announcements = Announcements.getInstance().getAnnouncements();
            //loadAnnouncements();
            writeC( Opcodes.S_OPCODE_COMMONNEWS );
            StringBuilder message = new StringBuilder();
            for ( int i = 0; i < _announcements.Count; i++ )
            {
                message.Append( _announcements[i].ToString() );
                message.Append( "\n" );
            }
            writeS( message.ToString() );
        }

        public S_CommonNews( String s )
        {
            writeC( Opcodes.S_OPCODE_COMMONNEWS );
            writeS( s );
        }

        override
        public byte[] getContent()
        {
            return getBytes();
        }

        override
        public String getType()
        {
            return "[S] S_CommonNews";
        }

        private static Logger _log = Logger.getLogger( typeof( S_CommonNews ).FullName );
    }
}